'''
from PIL import Image 
import glob, os
directory = "pred/"
for infile in glob.glob("*.JPEG"):
    file, ext = os.path.splitext(infile)
    im = Image.open(infile)
    rgb_im = im.convert('RGB')
    rgb_im.save(directory + file + ".png", "PNG")
'''


import os
import cv2

files = os.listdir("/home/aistudio/pred/")#获取当前目录下的文件
for filename in files:    
    portion = os.path.splitext(filename)#将文件名拆成名字和后缀    
    if portion[1] == ".JPEG":#关于后缀
        im = cv2.imread(filename)
        newname = portion[0]
        cv2.imwrite(newname + ".png", im)  
        os.remove(filename)


    if portion[1] == ".jpg":#关于后缀
        im = cv2.imread(filename)
        newname = portion[0]
        cv2.imwrite(newname + ".png", im)  
        os.remove(filename)




'''
import os
from PIL import Image 
files = os.listdir("/home/aistudio/pred/")#获取当前目录下的文件
for filename in files:
    
    portion = os.path.splitext(filename)#将文件名拆成名字和后缀
    
    if portion[1] == ".JPEG":#关于后缀
        im = Image.open(filename)
        rgb_im = im.convert('RGB')
        newname = portion[0] 
        rgb_im.save(newname + ".png", "PNG")
        os.remove(filename)
        #os.rename(filename, newname)#修改

    if portion[1] == ".jpg":#关于后缀
        im = Image.open(filename)
        rgb_im = im.convert('RGB')
        newname = portion[0] 
        rgb_im.save(newname + ".png", "PNG")
        os.remove(filename)
        #os.rename(filename, newname)#修改


'''
    